function parse_url(url: string) {
    var queryObj = {};
    var reg = /[?&]([^=&#]+)=([^&#]*)/g;
    var querys = url.match(reg);
    if (querys) {
        // console.log(querys);
        querys.forEach(element => {
            var query = element.split('=');
            var key = query[0].substring(1),
                value = query[1];
            queryObj[key] ? queryObj[key] = [].concat(queryObj[key], value) : queryObj[key] = value;
        })
    }
    return queryObj;
}

type KV = {
    [k: string]: any,
    token?: string,
    userId?: string,
    roomId?: string,
}

export const URLData: KV = parse_url(document.URL);



